package com.aidex.system.mapper;

import com.aidex.common.core.domain.entity.SysPost;
import com.aidex.common.core.domain.entity.SysRole;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface SysPostMapper extends BaseMapper<SysPost> {

    @Select("select p.* from sys_post p left join sys_user_post up on up.post_id = p.id left join sys_user u on u.id = up.user_id ${ew.customSqlSegment}")
    List<SysPost> selectListByUser(@Param("ew") QueryWrapper<SysPost> wrapper);

    @Select("select t.* from sys_post t left join sys_user_post up on up.post_id = t.id where up.user_id = #{id}")
    List<SysPost> selectListByUserId(@Param("id") String userId);

    @Select("select max(a.sort) from sys_post a where status = 0")
    Integer findMaxSort();

}
